<style type="text/css">
.ddtable tr td {
	text-align: center !important;
}

.ddtable .control-label {
	width: 100% !important;
	text-align: left !important;
}
</style>

<div class="ibox">
<div class="ibox-content">
	<form class="form-horizontal" id="addForm" action="${cxt!}/platform/operatorValidator/add" method="POST" >
	           <div class="form-group">
		             <label for="namebasic" class="col-md-2 control-label">URL<span class="fontColorRed">&nbsp;*</span></label>
		             <div class="col-md-3">
		              	<input type="text" class="form-control" name="operatorValidator.url" placeholder="URL"  required aria-required="true">
		             </div>
		             <label for="namebasic" class="col-md-2 control-label">${_res["systemManage.description"]}<span class="fontColorRed">&nbsp;*</span></label>
		             <div class="col-md-3">
		              	<input type="text" class="form-control" name="operatorValidator.description" placeholder="${_res['systemManage.description']}"  required aria-required="true">
		             </div>	             
	           </div>
	           <div class="hr-line-dashed"></div>
	           
	           <div class="form-group">
		             <label for="namebasic" class="col-md-2 control-label">ERROR URL<span class="fontColorRed">&nbsp;*</span></label>
		             <div class="col-md-3">
		              	<input type="text" class="form-control" name="operatorValidator.errorurl" placeholder="ERROR URL"  required aria-required="true">
		             </div>
	                <label class="col-sm-2 control-label">${_res["systemManage.menuStatus"]}<span class="fontColorRed">&nbsp;*</span></label>
	                <div class="col-sm-3">
	                    <#dict type="select" class="form-control" name="operatorValidator.status"  dictCode="COMMON_STATUS"  required="true"/>
	                </div>	           
	           </div>
	           <div class="hr-line-dashed"></div>
	            
			   <div class="row searchLineWrap">
					<p>
						<a href="javascript:void(0);" class="btn btn-primary pull-left" id="btn">${_res["systemManage.addValidatorParam"]}</a>
						<div class="clearfix"></div>
					</p>
					<table class="table table-bordered table-hover ddtable" id="table">
						<thead>
							<tr>
								<th width="13%">filed${_res["systemManage.name"]}</th>
								<th width="13%">filed</th>
								<th width="15%">${_res["systemManage.rule"]}</th>
								<th width="15%">${_res["systemManage.errorMessage"]}</th>
								<th width="15%">${_res["systemManage.errorMessageEn"]}</th>
								<th width="13%">extended1</th>
								<th width="15%">${_res["systemManage.menuStatus"]}</th>
								<th>${_res["system.operator"]}</th>
							</tr>
						</thead>
						<tbody>
							<tr>
								<td style="display:none"></td>
								<td><div><input type="text" class="form-control" name="operatorValidatorSetting1.fieldname" value=""  required aria-required="true"/></div></td>
								<td><div><input type="text" class="form-control" name="operatorValidatorSetting1.field" value=""  required aria-required="true"/></div></td>
								<td><div><#dict type="select" name="operatorValidatorSetting1.rule" dictCode="FORM_VALIDATOR"   required="true"/></div></td>
								<td><div><input type="text" class="form-control" name="operatorValidatorSetting1.message" value=""  required aria-required="true"/></div></td>
								<td><div><input type="text" class="form-control" name="operatorValidatorSetting1.messageen" value=""  required aria-required="true"/></div></td>
								<td><div><input type="text" class="form-control" name="operatorValidatorSetting1.extended1" value=""  /></div></td>
								<td><div><#dict type="select" name="operatorValidatorSetting1.status" dictCode="COMMON_STATUS"   required="true"/></div></td>
								<td><a href="javascript:void(0);" class="btn btn-primary pull-center" onclick="removeRow(this);" id="btn">${_res["system.delete"]}</a></td>
							</tr>
						</tbody>
					</table>
				</div>
				
				            
	            <div class="form-group">
	              <div class="col-md-10 col-md-offset-2">
	                <button type="button" class="btn btn-warning" onClick="ajaxContent('/platform/operatorValidator/list')">${_res["system.return"]}</button>
	                <button type="submit" class="btn btn-primary" >${_res["system.save"]}</button>
	                <button type="button" class="btn btn-danger" onClick="ajaxContent('/platform/operatorValidator/list')">${_res["system.cancel"]}</button>
	              </div>
	            </div>
	</form>
</div>
</div>


<!-- 动态添加的table  start -->
<table class="table table-bordered table-hover ddtable" id="copyTable" style="display:none">
	<tbody>
		<tr>
			<td style="display:none"></td>
			<td><div><input type="text" class="form-control" name="operatorValidatorSetting1.fieldname"  required aria-required="true"/></div></td>
			<td><div><input type="text" class="form-control" name="operatorValidatorSetting1.field"   required aria-required="true"/></div></td>
			<td><div><#dict type="select" name="operatorValidatorSetting1.rule" dictCode="FORM_VALIDATOR"    required="true"/></div></td>
			<td><div><input type="text" class="form-control" name="operatorValidatorSetting1.message"   required aria-required="true"/></div></td>
			<td><div><input type="text" class="form-control" name="operatorValidatorSetting1.messageen" value=""  required aria-required="true"/></div></td>
			<td><div><input type="text" class="form-control" name="operatorValidatorSetting1.extended1" value=""  /></div></td>
			<td><div><#dict type="select" name="operatorValidatorSetting1.status" dictCode="COMMON_STATUS"    required="true"/></div></td>
			<td><a href="javascript:void(0);" class="btn btn-primary pull-center" onclick="removeRow(this);" >${_res["system.delete"]}</a></td>
		</tr>
	</tbody>
</table>
<!-- 动态添加的table  end -->
<#submit  formId="addForm"  divId="content" />
<#nav />




<script>
$(function(){
	   //添加一行
	   $("#btn").bind("click",function() {
			//复制一行
			var $lastTR = $("#copyTable tbody tr").clone(true);
			$("#table tbody").append($lastTR);
			//添加序号	
			$("#table tr").each(function(i){
				  $(this).find("td:first-child").text(i);
			});
		    inputSelect();
	  });
	
	   function inputSelect(){
		   //input取name值和赋name值
		   var rowIndex = 0;
		   $("#table").each(function(){
			   $(this).find("tr").find("input").each(function(i){
				  var inputName=$(this).attr("name");
				  var inputNames = inputName.split(".");
				  var name = inputNames[0];
				  name = name.substring(0,name.length - (""+ name.match(/(\d+$)/g)).length);
				  var key =  inputNames[1];
				  var rowIndex = $(this).parents("tr").find("td:first-child").text();
				  var newInputName=name + rowIndex +"."+key;
				  $(this).attr("name",newInputName);
				});
			   
			   $(this).find("tr").find("select").each(function(i){
					  var inputName=$(this).attr("name");
					  var inputNames = inputName.split(".");
					  var name = inputNames[0];
					  name = name.substring(0,name.length - (""+ name.match(/(\d+$)/g)).length);
					  var key =  inputNames[1];
					  var rowIndex = $(this).parents("tr").find("td:first-child").text();
					  var newInputName=name + rowIndex +"."+key;
					  $(this).attr("name",newInputName);
					})
			 })
	    };
	});
	
	function removeRow(nowTr){
	  $(nowTr).parent().parent().remove(); 
	}
</script>